package com.zhsq.zlc.service.log;

import java.util.List;

import com.zhsq.zlc.dao.log.LogMapper;
import com.zhsq.zlc.entity.LogEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
public class LogServiceImpl implements LogService {

	private static final Logger logger = LoggerFactory.getLogger(LogServiceImpl.class);

	@Autowired
	private LogMapper logMapper;

	@Override
	@Transactional
	public List<LogEntity> list(LogEntity entity) throws Exception {
		return this.logMapper.list(entity);
	}

	@Override
	public void insertLog(String type, String content, String user, Boolean isSuccess) {
		try {
			LogEntity log = new LogEntity();
			log.setType(type);
			log.setContent(content);
			log.setUser(user);
			log.setIsSuccess(isSuccess);
			this.logMapper.insert(log);
		} catch (Exception e) {
			logger.error("", e);
		}
	}

	@Override
	@Transactional
	public int count(LogEntity entity) throws Exception {
		return this.logMapper.count(entity);
	}

	@Override
	public void cleanLog() throws Exception {
		logMapper.cleanLog();
	}
	@Override
	public void delete(int id) throws Exception {
		logMapper.delete(id);
	}

}
